<template>
	<view>
		<uni-nav-bar class="nav-bar" :fixed="true" color="#000" background-color="#ffffff" :border="false" :status-bar="true" @clickLeft="goSign" @clickRight="goRelease">
			<!-- 左边 -->
			<template slot="left">
				<view class="nav-left">
					<view class="iconfont iconqiandao"></view>
				</view>
			</template>
			<!-- 中间 -->
			<view class="nav-center row-center">
				<view :class="{'active':tabIndex === index}" @click="changeTab(index)" v-for="(item,index) in tabList" :key="index">{{item.name}}
					<view class="nav-line"></view>
				</view>
			</view>
			<!-- 右边 -->
			<template slot="right">
				<view class="nav-right">
					<view class="iconfont iconPensyumaobi"></view>
				</view>
			</template>
		</uni-nav-bar>
	</view>
</template>

<script>
	/*
	 * newsNavBar 动态页自定义导航栏
	 * @description 用于自定义导航栏
	 * @author MrThinco
	 * @property {Array} tabList 导航栏信息
	 * @property {Number} tabIndex 导航栏索引
	 */
	export default {
		props:{
			tabList: Array,
			tabIndex: Number
		},
		data() {
			return {
				
			};
		},
		methods:{
			// 签到
			goSign() {
				
			},
			// 发布
			goRelease() {
				// 打开发布页面
				this.$u.route('/pages/index/release');
			},
			// 切换标签
			changeTab(idx) {
				this.$emit('changeTab',idx);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.nav-bar{
		.iconfont {
			font-size: 30px;
			color: #01906c;
		}
		.iconfont:hover {
			color: #6ec679;
		}
		.nav-right {
			margin-left: auto;
		}
		.nav-center {
			width: 100%;
			text-align: center;
			view {
				font-size: 30rpx;
				padding: 0 15rpx;
				font-weight: bold;
				color: map-get($text-color,color3);
			}
		}
	}
	.active {
		color: map-get($text-color,color1);
		position: relative;
		display: flex;
		justify-content: center;
		align-items: center;
		.nav-line {
			border-top: 5rpx solid map-get($theme-color,orange);
			border-bottom: 5rpx solid map-get($theme-color,orange);
			width: 70rpx;
			border-radius: 20rpx;
			position: absolute;
			bottom: 0;
		}
	}
</style>
